package com.woniuxy.common.mapper;

import com.woniuxy.common.entity.ForumForum;
import com.woniuxy.common.entity.ForumForumExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ForumForumMapper {
    long countByExample(ForumForumExample example);

    int deleteByExample(ForumForumExample example);

    int deleteByPrimaryKey(String id);

    int insert(ForumForum record);

    int insertSelective(ForumForum record);

    List<ForumForum> selectByExample(ForumForumExample example);

    ForumForum selectByPrimaryKey(String id);

    int updateByExampleSelective(@Param("record") ForumForum record, @Param("example") ForumForumExample example);

    int updateByExample(@Param("record") ForumForum record, @Param("example") ForumForumExample example);

    int updateByPrimaryKeySelective(ForumForum record);

    int updateByPrimaryKey(ForumForum record);


    /**
    *@Author ArmWatt
    *@Date 2020/5/4
    *@Param
    *@return
    *@Description 初始化查重
    **/
    @Select("SELECT * FROM forum_forum WHERE name = #{name} OR phone = #{phone} OR address = #{address}")
    List<ForumForum> isExisted(@Param("name") String name,@Param("phone") String phone,@Param("address") String address);

    /**
    *@Author ArmWatt
    *@Date 2020/5/5
    *@Param [id, name, phone, address]
    *@return java.util.List<com.woniuxy.common.entity.ForumForum>
    *@Description 编辑查重
    **/
    @Select("SELECT * FROM forum_forum WHERE ( id <> #{id} ) AND ( name = #{name} OR phone = #{phone} OR address = #{address} )")
    List<ForumForum> isExistedForEdit(@Param("id") String id,@Param("name") String name,@Param("phone") String phone,@Param("address") String address);

}